//
//  Global.m
//  CarCollection2
//
//  Created by tangchunhui on 14/12/20.
//  Copyright (c) 2014年 go2matrix.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Global.h"
#import "MBProgressHUD.h"
#import "DataModal.h"
#import "User.h"

@interface Global(){
    MBProgressHUD *HUD1;
}

@end

@implementation Global

+ (Global *)instance  {
    static Global *instance;
    
    @synchronized(self) {
        if(!instance) {
            instance = [[Global alloc] init];
        }
    }
    return instance;
}
-(void)showMessageDelay:(NSString *)message
{
    
    UIWindow *window  = [[UIApplication sharedApplication] keyWindow];
    HUD1 = [[MBProgressHUD alloc ]initWithView:window ];
    HUD1.delegate = self;
    HUD1.mode = MBProgressHUDModeCustomView;
    HUD1.labelText = message;
    HUD1.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"notice.png"]];
    HUD1.dimBackground = NO;


    //hud显示需要在主线程完成
        [window addSubview:HUD1];
        [HUD1 show:NO];
        [HUD1 hide:YES afterDelay:1.0f];
    
}
-(void)showMessage:(NSString *)message on:(UIView *)view
{
    
    HUD1 = [[MBProgressHUD alloc ]initWithView:view ];
    HUD1.delegate = self;
    HUD1.mode = MBProgressHUDModeCustomView;
    HUD1.labelText = message;
    //HUD1.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"notice.png"]];
    HUD1.dimBackground = NO;
    [view addSubview:HUD1];
    [HUD1 show:YES];
    [HUD1 hide:YES afterDelay:1.0f];
    
 
}

#pragma mark -
#pragma mark MBProgressHUDDelegate methods

- (void)hudWasHidden:(MBProgressHUD *)hud {
    // Remove HUD from screen when the HUD was hidded
    [hud removeFromSuperview];
    hud = nil;
}

+(NSString *)host{
    return @"http://ybxx.doctorcao.com";
}
+(NSString *)serverip{
    NSArray *array= [[DataModal instance]queryData:@"User" whereString:@""];
    User *user= array[0];
    return user.serverip;
}
+(NSString *)weixinhao{
    NSArray *array= [[DataModal instance]queryData:@"User" whereString:@""];
    User *user= array[0];
    return user.weixinhao;
}

@end
